﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;


namespace WindowsFormsApp1
{
    class DbHelper
    {
        private static readonly string conString = "server=.;database=Ster;uid=sa;pwd=123456";

        public static DataTable FangPrint(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(conString);
            SqlDataAdapter adapter = new SqlDataAdapter(sql,sqlConnection);
            DataTable dt= new DataTable();
            adapter.Fill(dt);
            sqlConnection.Open();
            return dt;
            
             
        }
        public static int AddOrEdiSave(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(conString);
            SqlCommand sqlCommand = new SqlCommand(sql,sqlConnection);
            sqlConnection.Open();
            return sqlCommand.ExecuteNonQuery();

        }

    }
}
